Class sjl.OutputStreamIterator
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sjl.OutputStreamIterator

java.lang.Object
   |
   +----sjl.Iter
           |
           +----sjl.OutputStreamIterator

public class OutputStreamIterator
extends Iter
implements OutputIterator
To make it possible for the generic algorihms to work directly with output streams, the OutputStreamIterator have been created.
Ex:
    fout = new FileOutputStream("outputfile");
    OutputStreamIterator is = new OutputStreamIterator(fout, new WriteIntegerText(), " ");
    Algo.copy(vector.begin(), vector.end(), is);
The OutputStreamIterator writes (using the FuncTextWriter function object) successive elements onto the output stream (fout) for which it was contructed. The last argument, called a delimiter string, is written to the stream after each element is written. Ever time the put() method is called the element is written to the stream.

It is not possibly to get a value out of the output iterator. Its only use is as an output iterator is situation like this

    while (!first.cmp(last)) {
        result.put(first.get());
        result.next();
        first.next();
    }

Copyright © 1996 Finn Bock


Constructor Index

 o OutputStreamIterator(DataOutputStream, Function2, String)
Construct a OutputStreamIterator for the stream using the function object as a writer.
 o OutputStreamIterator(OutputStream, Function2, String)
Construct an OutputStreamIterator for the stream using the function object as a writer.

Method Index

 o cmp(Iterator)
Compare two iterators.
 o genericCopy()
XXX: Is this possible???
 o next()
Advance the iterator to the next element.
 o put(Object)
Write a value to the output stream.

Constructors

 o OutputStreamIterator
  public OutputStreamIterator(OutputStream ostream,
                              Function2 func,
                              String string)
Construct an OutputStreamIterator for the stream using the function object as a writer.
Parameters:
ostream - The iterator is constructed for this stream. A DataOutputStream is constructed for istream.
func - The function object used as a writer.
string - The delimiter string
See Also:
DataOutputStream
 o OutputStreamIterator
  public OutputStreamIterator(DataOutputStream ostream,
                              Function2 func,
                              String delim)
Construct a OutputStreamIterator for the stream using the function object as a writer.
Parameters:
ostream - The iterator is constructed for this stream.
string - The delimiter string

Methods

 o next
  public Iterator next()
Advance the iterator to the next element. Does nothing.
 o put
  public Object put(Object value)
Write a value to the output stream.
 o cmp
  public boolean cmp(Iterator iterator)
Compare two iterators.
Returns:
false.
 o genericCopy
  public Iterator genericCopy()
XXX: Is this possible???
Returns:
this

All Packages  Class Hierarchy  This Package  Previous  Next  Index